#ifndef SYSTEMCONFIG_H
#define SYSTEMCONFIG_H

#include "iniconfig.h"
#include "configdefine.h"

struct IniConfigID
{
    IniConfigID(QString s, QString k, QVariant v)
    {
        sector = s;
        key = k;
        defult = v;
    };

    QString sector;
    QString key;
    QVariant defult; // 默认值

    IniConfigID(QString sec = "", QString k = "")
    {
        sector = sec;
        key = k;
    }

    bool isNull()
    {
        return (sector.isEmpty() && key.isEmpty());
    }
};

class SystemConfig : public IniConfig
{
public:
    SystemConfig(const QString &fileName, QObject *parent = nullptr);

    void restoreDefault();
    bool init();

    bool get(ConfigKey key, QVariant &value);
    bool set(ConfigKey key, const QVariant &value);

    QList<ConfigKey> allKeys();
private:
    QMap<ConfigKey, IniConfigID> m_configIDMap;
};

#endif // SYSTEMCONFIG_H
